package com.iocup.keybastion.spring.starter.config;


import com.iocup.keybastion.spring.starter.filter.CorsSecurityFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.iocup.keybastion.spring.starter.config.CorsProperties.CORS_PROPERTIES;


/**
 * @author xyjxust
 * @create 2020/3/13 15:57
 **/
@Configuration
@ConditionalOnProperty(prefix = CORS_PROPERTIES, name = "enabled", havingValue = "true")
public class CorsConfig {



    @Autowired
    private CorsProperties corsProperties;


    @Bean
    public CorsSecurityFilter corsSecurityFilter(){
        return new CorsSecurityFilter(corsProperties);
    }
}
